<?php
namespace app\mini\model;

use Kingdee\Kingdee;
use think\facade\Db;
use app\common\traits\ActionRecordTrait;
use think\Model;
use app\admin\controller\ApiCommon;

use app\crm\model\CustomerLossModel;
use app\crm\model\OrderStatistics;
use app\admin\model\ShopOrderModel;
use app\admin\model\CustomerModel;
use app\admin\model\ShopModel;
use app\shop\model\Refund as OrderModel;
use app\mini\model\MiniStisticsModel;
use app\crm\model\ReserveandLost;

use app\mini\model\CustomerPointGoodsBuy;



class ActivityCustomerMiniModel extends Model
{
     /**

     * @var string

     */

    protected $name = 'admin_sys';
    protected $defaultSoftDelete = 0;
    protected $autoWriteTimestamp = true;


    public function getCard($request): array
    {

        $customer_id = $request['customer_id'] ?? '';

        $service_id = $request['service_id'] ?? '';

        $service_name = $request['service_name'] ?? '';

        if(!$customer_id){

            return ['error' => '未获取到用户信息，请确认是否登录', 'code' => 401];

        }

        $biaoqianCode = '635';

        $where = [];

        array_push($where,['id','=',$customer_id]);

        array_push($where,['member_label','like','%'.$biaoqianCode.'%']);

        $customer_info = Db::name('customer')->where($where)->find();

        $where = [];

        array_push($where,['shop_id','=',$customer_info['shop_id']]);

        array_push($where,['position_id','=','7']);

        $shop_personId = Db::name('shop_person')->where($where)->value('id');

        if(!$customer_info){

            return ['error' => '暂未获取活动资格！', 'code' => 401];

        }

        $nurse_id = $customer_info['nurse_id'] > '0' ? $customer_info['nurse_id'] : $shop_personId;

        $where = [];

        array_push($where,['customer_id','=',$customer_id]);

        array_push($where,['name','=',$service_name]);

        array_push($where,['status','=',1]);

        $customer_service = Db::name('service')->where($where)->find();

        if($customer_service){

            return ['error' => '您已经领取了该卡，请勿重复领取', 'code' => 401];

        }

        $addData = [

            'name' => $service_name,

            'shop_id' => $customer_info['shop_id'],

            'customer_id' => $customer_id,

            'service_type' => '2',

            'num' => '1',

            'start_time' => time(),

            'end_time' => strtotime('+1 year'),

            'create_time' => time(),

            'kk_user_id' => $nurse_id,

            'goods_id' => $service_id,

        ];

        $id = Db::name('service')->insertGetId($addData);

        if($id){

            return ['error' => '领取成功！', 'code' => 401];

        }

    }

    public function isGetCard($request): array
    {

        //$overlay_show 弹窗使用   $slide_show 轮播图使用

        $overlay_show = $slide_show =  false;
        $customer_id = $request['customer_id'] ?? '';
        if(in_array($customer_id,[594774,276115])){
            return [
                'overlay_show' => true,
                'slide_show'  => true
            ];
        }else{
            $where = [];
            array_push($where,['c.id','=',$customer_id]);
            // array_push($where,['id','=',$customer_id]);
            // $customerInfo = Db::name('customer')->where($where)->field('shop_id,telephone')->find();
            $result = Db::name('customer')->alias('c')
                ->join('shop s', 'c.shop_id = s.shop_id')
                ->where($where)
                ->where('c.consumption','>', 1)//消费金额 > 1元
                ->where('c.create_time','>', 1735660800) // 2025-01-01后
                ->where('s.status', 1)//运营中
                ->where('s.type','<>', 2)//直营店
                ->where('s.shop_type', 2)//门店
                ->field('c.id,c.shop_id')
                ->find();
                
            if(empty($result)){
                return [
                    'overlay_show' => $overlay_show,
                    'slide_show'  => $slide_show
                ];
            }else{
                $check = Db::name('question_customer')
                    ->where('customer_id',$result['id'])
                    ->where('shop_id',$result['shop_id'])
                    ->where('questionnaire_id',9)
                    ->count();
                    
                if($check > 0){
                    return [
                        'overlay_show' => $overlay_show,
                        'slide_show'  => $slide_show
                    ];
                }else{
                    $overlay_show = $slide_show =  true;
                }
            }
            
            // $activity = DB::name('activity')->where('id',1)->find();
            // if($activity['begin_time'] <= time() && time() <= $activity['end_time'] ){
            //     $jm_shop = DB::name('shop')->where('type',2)->column('shop_id');
            //     $sitout_market_id = explode(',',$activity['sitout_market_ids']); //
            //     $shop_id = $customerInfo['shop_id'];
            //     $map = [
            //         ['type','<>',2],
            //         ['status','=',1],
            //         ['shop_type','=',2],
            //         ['market_id','not in',$sitout_market_id]
            //     ];
            //     $show_shop_ids = DB::name('shop')->where($map)->column('shop_id');

            //     if(in_array($shop_id,$show_shop_ids)){
            //         $overlay_show = $slide_show =  true;
            //     }

            //     $day_time  = date('Ymd');
            //     $count = DB::name('activity_customer')->where('customer_id',$customer_id)->where('createtime',$day_time)->count();
            //     //顾客领取当天领取机会次数
            //     if($count >=1){
            //         $overlay_show = false;
            //     }
            //     //加盟店不参加
            //     if(in_array($shop_id,$jm_shop)){
            //         $overlay_show = $slide_show =  false;
            //     }
            // }
        }
        return [
            'overlay_show' => $overlay_show,
            'slide_show'  => $slide_show
        ];
    }

    public function downPointGoods($request):array
    {
        $customer_id = $request['customer_id'] ?? '';

        $pointGoodsId = $request['point_goods_id'] ?? '28';

        $where = [];

        array_push($where,['customer_id','=',$customer_id]);

        array_push($where,['point_goods_id','=',$pointGoodsId]);

        $isGet = Db::name('customer_point_goods_buy')->where($where)->select()->toArray();

        if($isGet){

            return ['error' => '您已经领取了该卡，请勿重复领取', 'code' => 401];

        }

        Db::startTrans();
        try {
            $customerPointGoodsBuy = new CustomerPointGoodsBuy();
            $customerPointGoodsBuy->save([
                'point_goods_id'=>$pointGoodsId,
                'customer_id'=>$customer_id,
                'status'=>1,
                'start_time'=>strtotime('2024-03-08'),
                'end_time'=>strtotime('2024-03-11 23:59:59'),
            ]);
            CustomerPointModel::pointChange($customer_id,'42');
            Db::commit();
            return ['error' => '领取成功！', 'code' => 401];
        } catch (\Exception $e) {
            Db::rollback();
            return ['error' => '领取失败！', 'code' => 401];
        }
    }

    public function downServiceCard($request):array
    {
        $cardIds = [165,168];

        $customer_id = $request['customer_id'] ?? '';

        if(!$customer_id){

            return ['error' => '客户信息错误！', 'code' => 401];

        }

        $shop_id = Db::name('customer')->where('id',$customer_id)->value('shop_id');

        $goods_name = Db::name('shop_goods')->where([['id','in',$cardIds]])->column('name','id');

        $where = [];

        array_push($where,['goods_id','in',$cardIds]);
        array_push($where,['customer_id','=',$customer_id]);
        array_push($where,['order_id','=','']);

        $res = Db::name('service')->where($where)->select()->toArray();

        if($res){

            return ['error' => '您已经领取了该卡，请勿重复领取', 'code' => 401];

        }

        if($request['type'] == 1){
            $cardId = 168;
            $num = 2;
        }

        if($request['type'] == 2){
            $cardId = 165;
            $num = 1;
        }

        $addData = [
            'name' => $goods_name[$cardId],
            'shop_id' => $shop_id,
            'customer_id' => $customer_id,
            'service_type' => 2,
            'num' => $num,
            'status' => 1,
            'experience' => 1,
            'goods_id' => $cardId,
            'create_time' => time(),
        ];

        $id = Db::name('service')->insertGetId($addData);

        if($id){
            return ['error' => '领取成功！', 'code' => 401];
        }else{
            return ['error' => '领取失败！', 'code' => 401];
        }

    }
    /*
     * 获取顾客可领取次数商品
     * */
    public function activityCustomerNum($request):array
    {
        $activity_id = $request['activity_id'] ??0;
        $customer_id = $request['customer_id'] ??0;
        $shop_id = $request['shop_id'] ?? 0;

        try {
            if(empty($activity_id) || empty($customer_id) || empty($shop_id)){
                return ['error' => '参数不合法！', 'code' => 401];
            }
            $where = [
                'shop_id' => $shop_id,
                'customer_id' => $customer_id,
                'activity_id' => $activity_id,
                'draw_time'=>0,
            ];
            $draw_num = DB::name('activity_customer')->where($where)->count();
            return ['data'=>$draw_num];
        } catch (\Exception $e) {
            return ['error' => '获取可领取次数失败！', 'code' => 401,];
        }
    }
    /*
     * 活动详情
     * */
    public function activityDetail($request):array{
        $activity_id = $request['activity_id'] ??0;
        $activity = DB::name('activity')->where('id',$activity_id)->find();
        if(!empty($activity)){
            $goods = $activity['goods_id'];
            $goods_ids = explode(',',$goods);
            $activity['goods']=DB::name('shop_goods')->whereIn('id',$goods_ids)->field('id,name,img')->select()->toArray();
            $activity['begin_time'] = date('Y-m-d H:i:s',$activity['begin_time']);
            $activity['end_time'] = date('Y-m-d H:i:s',$activity['end_time']);
        }
        return ['data'=>$activity];
    }

    /*
     * 获取顾客可领取次数商品
     * */
    public function customerDrawGoods($request):array
    {

        $activity_id = $request['activity_id'] ??0;
        $customer_id = $request['customer_id'] ??0;
        $shop_id = $request['shop_id'] ?? 0;
        $draw_goods = $request['draw_goods'] ??'';
        Db::startTrans();
        try {

            if(empty($activity_id) || empty($customer_id) || empty($shop_id) || empty($draw_goods)){
                throw new \Exception('参数不合法！');
            }
            $activity = DB::name('activity')->where('id',$activity_id)->lock(true)->find();
            if(empty($activity)){
                throw new \Exception('活动不存在！');
            }
            if($activity['begin_time'] > time() || time() > $activity['end_time']){
                throw new \Exception('活动未开始或已结束！');
            }
            $activity_goods = explode(',',$activity['goods_id']);
            $shop_goods = DB::name('shop_goods')->whereIn('id',$activity_goods)
                ->field('id,name,category_id,goods_sn,kingdee_code,goods_price,spec_name,unit_code,unit_name,is_project')
                ->select()->toArray();
            $shop_goods = array_column($shop_goods,null,'id');
            $goods_price = [];
            $goods_price_sum = 0;
            foreach($draw_goods as $k=>$v){
                if(isset($shop_goods[$v['id']])){
                    $price = bcmul($shop_goods[$v['id']]['goods_price'],$v['num'],2);
                    array_push($goods_price,$price);
                }
            }
            $goods_price_sum = array_sum($goods_price);

            $shop = ShopModel::with(['store'=>function($query)use($shop_id){
                $query->field('id,name,kingdee_code');
            }])->where('shop_id',$shop_id)->find();
            if(empty($shop)){
                throw new \Exception('门店不存在！');
            }
            $customer = DB::name('customer')->where('id',$customer_id)->find();
            if(empty($customer)){
                throw new \Exception('顾客信息不存在！');
            }

            $day_time = date('Ymd');
            $where = [
                'customer_id' => $customer_id,
                'activity_id' => $activity_id,
                'draw_time'=>$day_time,
            ];
            $draw_num = DB::name('activity_customer')->where($where)->count();
            if($draw_num >0){
                throw new \Exception('今日已经领取！');
            }

            $public_where=[
                ['shop_id','=',$shop_id],
                ['status','=',1],
            ];
            $where = [
                ['position_id','=',7]
            ];
            $dzhang = DB::name('shop_person')->where($public_where)->where($where)->find();
            $where = [
                ['position_id','=',10]
            ];
            $dzhu = DB::name('shop_person')->where($public_where)->where($where)->find();
            $where = [
                ['position_id','not in',[7,10]]
            ];
            $hls = DB::name('shop_person')->where($public_where)->where($where)->find();
            if(empty($dzhang) && empty($dzhu) &&  empty($hls) ){
                return ['error' => '该门店无工作人员', 'code' => 401];
            }

            if(!empty($dzhang)){
                $kdr_id = $dzhang['id'];
                $kdr_name = $dzhang['name'];
            }else{
                if(!empty($dzhu)){
                    $kdr_id = $dzhu['id'];
                    $kdr_name = $dzhu['name'];
                }else{
                    $kdr_id = $hls['id'];
                    $kdr_name = $hls['name'];
                }
            }

            $zdr_id = $zdr_name = '';
            $dzhu['phone'] = !empty($dzhu['phone'])?$dzhu['phone']:'';
            $dzhang['phone'] = !empty($dzhang['phone'])?$dzhang['phone']:'';
            $hls['phone'] = !empty($hls['phone'])?$hls['phone']:'';
            $admin_user = DB::name('admin_user')->where('mobile',$dzhu['phone'])->field('realname,id')->find();

            if(!empty($admin_user)){
                $zdr_id = $admin_user['id'];
                $zdr_name = $admin_user['realname'];
            }else{
                $admin_user = DB::name('admin_user')->where('mobile',$dzhang['phone'])->field('realname,id')->find();

                if(!empty($admin_user)){
                    $zdr_id = $admin_user['id'];
                    $zdr_name = $admin_user['realname'];
                }else{
                    $admin_user = DB::name('admin_user')->where('mobile',$hls['phone'])->field('realname,id')->find();
                    if(!empty($admin_user)){
                        $zdr_id = $admin_user['id'];
                        $zdr_name = $admin_user['realname'];
                    }
                }
            }
            if(empty($zdr_id) || empty($zdr_name)){
                throw new \Exception('暂无制单人，请联系工作人员！');
            }

            $where = [
                'customer_id' => $customer_id,
                'activity_id' => $activity_id,
                'draw_time'=>0,
            ];
            $draw_ids = DB::name('activity_customer')->where($where)->column('id');
            $draw_num = count($draw_ids); //可领取次数
            $draw_goods_num = array_column($draw_goods,'num');
            $draw_goods_sum_num = array_sum($draw_goods_num); //输入的领取次数
            if($draw_goods_sum_num > $draw_num){
                throw new \Exception('超出可领取次数');
            }
            if($draw_goods_sum_num <1){
                throw new \Exception('请正确输入领取次数');
            }

            $orderModel = new \app\shop\model\Order();
            $time = time();
            $day_time = strtotime(date('Y-m-d')); //当天日期时间戳
            //生成一个免费的出库单-并且推到云星空

            $data = [
                'uid'        => $customer_id, // 客户
                'source_id'   => $customer['source_id'], //顾客来源
                'consignee'         => $customer['customer_name'], // 收货人
                'order_no'          => $orderModel->getOrderNo(), // 订单号
                'sale_id'           => $kdr_id, // 销售员id
                'sale_name'           => $kdr_name, // 销售员姓名
                'shop_id'           => $shop_id, // 门店id
                'shop_name'           => $shop['shop_name'], // 门店名称
                'operator_id'       => $zdr_id,//制单员id
                'operator_name'       => $zdr_name,//制单员姓名
                'create_time'       => $time, // 创建时间
                'deal_time'         => $day_time, // 成交日期
                'goods_price'      => $goods_price_sum, // 订单标准金额
                'total_amount'      => 0, // 订单总金额
                'pay_amount'        => 0 , // 实收本金
                'discount_amount'   =>0, // 订单优惠金额
                'gift_amount'        =>  0, // 实收赠金
                'shop_transfer_amount' => 0, //实收店转
                'order_amount'      =>  0, // 订单优惠金额
                'is_experience'     => 0, // 是否体验 0否 1是
                'experience_id'       =>  0, // 体验人id
                'experience_name'       => '', // 体验人姓名
                'is_outreach'       => 0, // 是否外联 0否 1是
                'coupon_id'       =>  0, // 优惠券id
                'coupon_name'       =>  0, // 优惠券id
                'outreahc_id'       =>  0, // 外联人id
                'outreahc_name'       =>  '', // 外联人姓名
                'is_introduction'       => 0, // 是否转介绍 0否 1是
                'introduction_id'       =>  0, // 转介绍人id
                'introduction_name' =>  '', // 转介绍人姓名
                'description'       =>  '25年2月开年焕颜福利', // 订单描述
                'order_type'        => 2, // 订单类型 1新单 2补单
                'project_type'      =>  0, // 项目分类
                'business_type'     => 1, // 业务类型 1项目 2疤痕 3青春痘 4护肤品
                'income_type'       => 1, // 收入类型 1 服务（各类疗程卡项及疗程卡项赠送产品）2 产品销售（单独付费购买产品）3 医美收入
                'market_id'         => $shop['market_id'], // 市场id
                'market_name'       => $shop['market_name'], // 市场名称
                'sales_policy'      => '', // 销售政策编码
                'sales_organization'  => $shop['market_kingdee_code'], // 销售组织编码
                'sales_name'       => $shop['market_name'], // 销售组织名称
                'settlement_organization'  => $shop['market_kingdee_code'], // 结算组织编码
                'settlement_name'       => $shop['market_name'], // 结算组织名称
                'order_experience'      =>'' ,//订单是否有体验商品
                'delivery_name'       => $shop['shop_name'], // 发货部门名称
                'delivery_king'       => isset($shop['keycode']) ? $shop['keycode'] : '', // 发货部门编码
                'business_two_type'  => 2,// 业务类型二级分类  1身体项目  2 皮肤项目
            ];

            $order_id = DB::name('shop_order')->insertGetId($data);

            //修改领取机会记录、生成服务卡项
            $arrayIndex = 0;
            $serviceDataAll=[];
            foreach($draw_goods as $k=>&$v) {
                $num = $v['num'];
                if($num >0){
                    //生成服务卡项
                    $orderGoodsList[$k]['order_id'] = $order_id;
                    $orderGoodsList[$k]['create_time'] = $time;
                    $orderGoodsList[$k]['goods_id'] = $v['id'];
                    $orderGoodsList[$k]['goods_name'] = $v['name'];
                    $orderGoodsList[$k]['kingdee_code'] = isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['kingdee_code']:'';
                    $orderGoodsList[$k]['goods_price'] =  isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['goods_price']:'';
                    $orderGoodsList[$k]['pay_price'] = 0;
                    $orderGoodsList[$k]['spec_name'] = isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['spec_name']:'';
                    $orderGoodsList[$k]['unit_code'] = isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['unit_code']:'';
                    $orderGoodsList[$k]['unit_name'] =  isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['unit_name']:'';
                    $orderGoodsList[$k]['number'] = 1;
                    $orderGoodsList[$k]['desc'] = '25年38大促活动';
                    $orderGoodsList[$k]['is_project'] = isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['is_project']:'';//是否服务 1 是 2否
                    $orderGoodsList[$k]['category_id'] =  isset($shop_goods[$v['id']])?$shop_goods[$v['id']]['category_id']:'';
                    $orderGoodsList[$k]['is_coupon_goods'] = isset($v['is_coupon_goods']) ? $v['is_coupon_goods'] : 0;//是否优惠券商品 0否 1是
                    $orderGoodsList[$k]['project_type'] = 1;//服务类型 1 按次 2按天
                    $orderGoodsList[$k]['service_number'] = $v['num'];//服务次数
                    $orderGoodsList[$k]['start_time']     = isset($v['start_time']) ? strtotime($v['start_time']) : 0;
                    $orderGoodsList[$k]['end_time'] = isset($v['end_time']) ? strtotime($v['end_time']) : 0;
                    $orderGoodsList[$k]['is_gift'] = isset($v['is_gift']) ? $v['is_gift'] : 0;
                    $orderGoodsList[$k]['house_code'] = empty($shop['store'])?'':$shop['store'][0]['kingdee_code'];  //仓库编码
                    $orderGoodsList[$k]['coupon_type'] = isset($v['coupon_type']) ? $v['coupon_type'] : 0;//优惠券类型
                    $orderGoodsList[$k]['house_code_name'] = empty($shop['store'])?'':$shop['store'][0]['name']; //仓库名称
                    $orderGoodsList[$k]['nurse_one'] = isset($v['nurse_one']) ?$v['nurse_one'] :0;
                    $orderGoodsList[$k]['nurse_one_project'] = isset($v['nurse_one_project']) ? implode(',',$v['nurse_one_project']):'';
                    $orderGoodsList[$k]['nurse_two'] = isset($v['nurse_two']) ?$v['nurse_two'] :0;
                    $orderGoodsList[$k]['nurse_two_project'] = isset($v['nurse_two_project']) ? implode(',',$v['nurse_two_project']):'';
                    $orderGoodsList[$k]['goods_alias_name'] = isset($v['goods_alias_name']) ? $v['goods_alias_name']:'';
                    for($i=1;$i<=$orderGoodsList[$k]['number'];$i++){
                        $oneService = [];
                        $oneService['name']    = $orderGoodsList[$k]['goods_name'];  //服务名称
                        $oneService['num']     = $orderGoodsList[$k]['service_number'];   // 必填--服务类型：1按期2按次
                        $oneService['shop_id'] = $data['shop_id'];    // 店铺id
                        $oneService['customer_id']  = $data['uid'];   // 必填--客户id
                        $oneService['order_id']  = $order_id;
                        $oneService['service_type'] = $orderGoodsList[$k]['project_type']==1?2:1;   // 必填--服务类型：1按期2按次
                        $oneService['start_time']   = $orderGoodsList[$k]['start_time'];    // 类型为1是必填--服务开始时间
                        $oneService['end_time']     = $orderGoodsList[$k]['end_time'];      // 类型为1是必填--服务开始时间
                        $oneService['experience']   = $data['is_experience'];     // 0否1是 是否体验
                        $oneService['kk_user_id']   = $data['sale_id'];     // 开卡人id
                        $oneService['kk_money']     = 0;       // 开卡金额
                        $oneService['goods_id']     = $orderGoodsList[$k]['goods_id'];       // 商品id
                        $oneService['consume_store_transfer'] = 0;
                        $oneService['consume_gratuity'] = 0;
                        $oneService['consume_money'] = 0;
                        $oneService['first_month_max_service_num'] = 0;
                        $oneService['middle_month_max_service_num'] = 0;
                        $oneService['end_month_max_service_num'] = 0;
                        $oneService['service_max_num'] = $orderGoodsList[$k]['service_number']; //最高进店次数
                        $oneService['category_id']  = $orderGoodsList[$k]['category_id'];       // 开卡金额
                        $oneService['customer_activity_id'] = 1;
                        $oneService['use_begin_time'] = $activity['service_use_begintime'];
                        $oneService['use_end_time'] = $activity['service_use_endtime'];
                        $oneService['create_time'] = $time;
                        array_push($serviceDataAll,$oneService);
                    }

                    $ids = [];
                    for ($i = 0; $i < $num; $i++) {
                        if ($arrayIndex < $draw_num) {
                            $ids[] = $draw_ids[$arrayIndex];
                            $arrayIndex++;
                        }
                    }

                    if (!empty($ids)) {
                        $time = time();
                        $update = [
                            'draw_time' => $time,
                            'goods_id' => $v['id'],
                            'update_time' => $time
                        ];
                        $res = DB::name('activity_customer')->whereIn('id', $ids)->update($update);
                        if(!$res){
                            throw new \Exception('领取失败');
                        }
                    }
                }
            }
            if(!empty($orderGoodsList)){
                $res  = Db::name('shop_order_goods')->insertAll($orderGoodsList);
                if(!$res){
                    throw new \Exception('生成订单失败，请稍后重试！');
                }
            }

            if(!empty($orderGoodsList)){
                $res  = Db::name('service')->insertAll($serviceDataAll);
                if(!$res){
                    throw new \Exception('生成卡项失败，请稍后重试！');
                }
            }
            //推送云星空代码
            $customerModel = new \app\crm\model\Customer();
            if ($shop['type'] != 2)
            {
                $res = $customerModel->pushKingCustomer($customer_id);
                if($res == false){
                    throw new \Exception($customerModel->getError());
                }
                $kingDee = new Kingdee();
                $result=$kingDee->send_order($order_id);
                if ($result['code']) {
                    throw new \Exception($result['msg']);
                }
            }
            Db::commit();
            return ['code' => 200,'data'=>[]];
        } catch (\Exception $e) {
            Db::rollback();
            //领取失败
            return ['error'=>$e->getMessage()];
        }

    }







}
